package com.xpc.mapper;

import com.xpc.pojo.qin.DepartmentSimpleInfo;
import com.xpc.pojo.qin.DepartmentSimpleInfo_Member;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

import static com.xpc.constant.PositionConstant.*;

/**
 * @author Qinkuer
 * @version 1.0.0
 * @ProjectName UniversityGradeAdministrationSystem
 * @ClassName DepartmentSimpleInfoMapper.java
 * @Description TODO
 * @createTime 2022年05月26日 14:07:00
 */
@Mapper
public interface DepartmentSimpleInfoMapper {


    /**
        * @description 获取所有部门的粗略信息
        * @return  java.util.List<com.xpc.pojo.qin.DepartmentSimpleInfo>
        * @author Qinkuer
        * @Date  2022/5/26
        */
    @Select("select dcg.id as departmentId ,dcg.name as departmentName,count(mcg.id) as nums from \n" +
            "department_committee_grade dcg \n" +
            "left join member_committee_grade mcg ON dcg.id =mcg.d_c_g_id \n" +
            "group by dcg.id order by departmentId ")
    List<DepartmentSimpleInfo> getList();
//    select dcg.id as departmentId ,dcg.name as departmentName,count(mcg.id) as nums from
//    department_committee_grade dcg
//    left join member_committee_grade mcg ON dcg.id =mcg.d_c_g_id
//    group by dcg.id


    /**
        * @description 获取所有部门干部信息
        * @return  java.util.List<com.xpc.pojo.qin.DepartmentSimpleInfo_Member>
        * @author Qinkuer
        * @Date  2022/5/26
        */
    @Select("select mcg.*,a.account_id as accountId from\n" +
            "\t(select mcg.*,u.name from \n" +
            "\t\t(select mcg.id as committeeGradeId,mcg.d_c_g_id as departmentId,mcg.user_id as userId,mcg.position_id as positionId,p.name as positionName from\n" +
            "\t\t\t(select * from member_committee_grade mcg where mcg.position_id  in ("+MINISTER_INT+","+UNDERSECRETARY_INT+","+DEPARTMENT_PRINCIPAL_INT+","+GRADE_PRINCIPAL_INT+","+DEPUTY_GRADE_PRINCIPAL_INT+")) as mcg \n" +
            "\t\tleft join `position` p on mcg.position_id =p.id  ) as mcg\n" +
            "\tleft join `user` u on mcg.userId=u.user_id )as mcg \n" +
            "left join account a on mcg.userId=a.user_id ")
    List<DepartmentSimpleInfo_Member> getTopMembersList();
//    select mcg.*,a.account_id as accountId from
//            (select mcg.*,u.name from
//		(select mcg.id as committeeGrageId,mcg.d_c_g_id as departmentId,mcg.user_id as userId,mcg.position_id as positionId,p.name as positionName from
//                     (select * from member_committee_grade mcg where mcg.position_id  in (11,12,14,16,17)) as mcg
//    left join `position` p on mcg.position_id =p.id  ) as mcg
//    left join `user` u on mcg.userId=u.user_id )as mcg
//    left join account a on mcg.userId=a.user_id

}
